/**
* @private
* @license	GNU GPLv2
*
* Copyright (C) 2007  Polly Jex.
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
* MA  02110-1301, USA.
*
* @see	http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/

package test {

	/**
	 * @import
	 */
	
	import com.airlogger.AirLoggerDebug;
	import com.kirika.core.CoreStatic;
	import com.kirika.data.IIterator;
	import com.kirika.data.IQueue;
	import com.kirika.data.tda.AbstractCollection;
	import com.kirika.data.tda.AbstractQueue;
	import com.kirika.utils.ClassUtil;
	
	/**
	 * Test Abstract Collection
	 * @author	Polly Jex (pollyjex@emc2zen.com.ar)
	 */
	public class TestAbstractQueue extends CoreStatic {
		
		public static function test():void {
			
			AirLoggerDebug.INFO( 'INITIALIZE: ' + ClassUtil.shortName( TestAbstractQueue ) );
			
			var arr:Array = [ 1, 2, 3, 4, 5, 6 ];
			var aq:IQueue = new AbstractQueue( arr, 3 );
			
			AirLoggerDebug.INFO( "ITERATOR" );
			
			var i:IIterator = aq.iterator();
			
			while( i.hasNext() ){
				i.next();
				AirLoggerDebug.DEBUG( 'ITERATOR (' + i.index() + '): ' + i.value() ); 
			}
			
			AirLoggerDebug.INFO( "CAPACITY : AVAILABLE : SIZE" );
			
			AirLoggerDebug.DEBUG( aq.capacity() +" : "+ aq.available() +" : "+ aq.size() );
			
			AirLoggerDebug.INFO( "ELEMENT" );
			
			AirLoggerDebug.DEBUG( aq.element() );
			AirLoggerDebug.DEBUG( aq.capacity() +" : "+ aq.available() +" : "+ aq.size() );
			
			AirLoggerDebug.INFO( "PEEK" );
			
			AirLoggerDebug.DEBUG( aq.peek() );
			AirLoggerDebug.DEBUG( aq.capacity() +" : "+ aq.available() +" : "+ aq.size() );
			
			AirLoggerDebug.INFO( "POLL" );
			
			AirLoggerDebug.DEBUG( aq.poll() );
			AirLoggerDebug.DEBUG( aq.poll() );
			AirLoggerDebug.DEBUG( aq.poll() );
			AirLoggerDebug.DEBUG( aq.poll() );
			AirLoggerDebug.DEBUG( aq.poll() );
			AirLoggerDebug.DEBUG( aq.capacity() +" : "+ aq.available() +" : "+ aq.size() );
			
			AirLoggerDebug.INFO( "PEEK" );
			
			AirLoggerDebug.DEBUG( aq.peek() );
			AirLoggerDebug.DEBUG( aq.peek() );
			AirLoggerDebug.DEBUG( aq.peek() );
			AirLoggerDebug.DEBUG( aq.peek() );
			AirLoggerDebug.DEBUG( aq.capacity() +" : "+ aq.available() +" : "+ aq.size() );
			
			AirLoggerDebug.INFO( "ELEMENT" );
			
			try { 
				AirLoggerDebug.DEBUG( aq.element() ); 
			} catch( e:Error ) { 
				AirLoggerDebug.ERROR( e ); 
			}
			
			AirLoggerDebug.DEBUG( aq.capacity() +" : "+ aq.available() +" : "+ aq.size() );
			
			AirLoggerDebug.INFO( "ADD_ALL: 10" );
			
			AirLoggerDebug.DEBUG( aq.addAll( new AbstractCollection( arr ) ) );
			AirLoggerDebug.DEBUG( aq.capacity() +" : "+ aq.available() +" : "+ aq.size() );
			
			AirLoggerDebug.INFO( "ADD_ALL: 3" );
			
			AirLoggerDebug.DEBUG( aq.addAll( new AbstractCollection( ["A","B","A"] ) ) );
			AirLoggerDebug.DEBUG( aq.capacity() +" : "+ aq.available() +" : "+ aq.size() );
			
			AirLoggerDebug.INFO( "ITERATOR" );
			
			i = aq.iterator();
			
			while( i.hasNext() ){
				i.next();
				AirLoggerDebug.DEBUG( 'ITERATOR (' + i.index() + '): ' + i.value() ); 
			}
			
			AirLoggerDebug.INFO( "REMOVE" );
			
			AirLoggerDebug.DEBUG( aq.remove( "A" ) );
			AirLoggerDebug.DEBUG( aq.capacity() +" : "+ aq.available() +" : "+ aq.size() );
			
			AirLoggerDebug.INFO( "ITERATOR" );
			
			i = aq.iterator();
			
			while( i.hasNext() ){
				i.next();
				AirLoggerDebug.DEBUG( 'ITERATOR (' + i.index() + '): ' + i.value() ); 
			}
			
		}
		
	}
	
}
